<template>
	<div>
		<div v-show="op" class="Arrow">
			<span class="iconfont" @click="Return">&#xe624;</span>
		</div>

		<div class="header" v-show="!op" :style="opc">
			<div class="md-header">
				<span class="iconfont" @click="Return">&#xe624;</span>
				<h1>大汖温泉</h1>
			</div>
		</div>

	</div>
</template>

<script>
	export default {
		data() {
			return {
				op: true,
				opc: {
					opacity: 0
				}
			}
		},
		methods: {
			Return() {
				this.$router.push('/');
			}
		},
		mounted() {
			window.addEventListener('scroll', () => {

				if(document.documentElement.scrollTop) {
					let top = document.documentElement.scrollTop;

					let opcity = top / 200;

					if(top > 50) {
						this.opc.opacity = opcity;
						if(this.opc.opacity == 1) {
							this.opc.opacity = 1;
						}
						this.op = false;
					} else {
						this.op = true
					}
				} else {
					let top = document.body.scrollTop;

					let opcity = top / 200;

					if(top > 50) {
						this.opc.opacity = opcity;
						if(this.opc.opacity == 1) {
							this.opc.opacity = 1;
						}
						this.op = false;
					} else {
						this.op = true
					}
				}

			})
		},
		activated() {

			if(document.documentElement.scrollTop) {
				document.documentElement.scrollTop = 0;
			} else {
				document.body.scrollTop = 0;
			}

		}
	}
</script>

<style scoped="scoped">
	.content {
		height: 2000px;
	}
	
	.md-header {
		position: fixed;
		width: 100%;
		top: 0px;
		left: 0px;
		display: block;
		opacity: 1;
		height: .88rem;
		background: #00bcd4;
		z-index: 91;
	}
	
	.md-header span {
		position: absolute;
		font-size: .36rem;
		color: #fff;
		text-align: center;
		left: 0;
		top: 0;
		width: .8rem;
		height: .88rem;
		line-height: .88rem;
	}
	
	.md-header h1 {
		overflow: hidden;
		margin: 0 1rem;
		line-height: .88rem;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: .32rem;
		text-align: center;
		color: #fff;
	}
	
	.Arrow span {
		width: .72rem;
		height: .72rem;
		border-radius: 50%;
		background: #000000;
		color: #fff;
		display: flex;
		position: absolute;
		left: .1rem;
		top: .1rem;
		align-items: center;
		justify-content: center;
		font-size: .33rem;
		font-weight: bold;
	}
</style>